package com.tancire.web.controller.net;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.net.domain.AuthLog;
import com.tancire.net.service.IAuthLogService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 认证日志Controller
 *
 * @author chenchao
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/net/authLog")
public class AuthLogController extends BaseController {

    @Resource
    private IAuthLogService authLogService;

    /**
     * 查询认证日志列表
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuthLog authLog) {
        startPage();
        List<AuthLog> list = authLogService.selectAuthLogList(authLog);
        return getDataTable(list);
    }

    /**
     * 导出认证日志列表
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:export')")
    @Log(title = "认证日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuthLog authLog) {
        List<AuthLog> list = authLogService.selectAuthLogList(authLog);
        ExcelUtil<AuthLog> util = new ExcelUtil<AuthLog>(AuthLog.class);
        util.exportExcel(response, list, "认证日志数据");
    }

    /**
     * 获取认证日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(authLogService.selectAuthLogById(id));
    }

    /**
     * 新增认证日志
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:add')")
    @Log(title = "认证日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuthLog authLog) {
        return toAjax(authLogService.insertAuthLog(authLog));
    }

    /**
     * 修改认证日志
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:edit')")
    @Log(title = "认证日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuthLog authLog) {
        return toAjax(authLogService.updateAuthLog(authLog));
    }

    /**
     * 删除认证日志
     */
    @PreAuthorize("@ss.hasPermi('net:authLog:remove')")
    @Log(title = "认证日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(authLogService.deleteAuthLogByIds(ids));
    }
}
